package Java.BlackHorse.a02StreamTest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test3 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1,"蔡坤坤,24","叶齁咸,23","刘不甜,22","吴签,24","谷嘉,30","肖凉凉,27");
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2,"赵小颖,35","杨颖,36","高圆圆,43","张天天,31","刘诗,35","杨小幂,33");

        Stream<String> stream1 = list1.
                stream().
                filter(s -> s.split(",")[0].length() == 3).
                limit(2);

        Stream<String>  stream2 = list2.
                stream().
                filter(s -> s.split(",")[0].startsWith("杨")).
                skip(1);

        /*Stream.concat(stream1,stream2).map( s -> {
                String name = s.split(",")[0];
                int age =Integer.parseInt(s.split(",")[1]);
                return new Actor(name,age);

        }).forEach(s -> System.out.println(s));*/


        List<Actor> collect = Stream.
                concat(stream1, stream2).
                map(s -> new Actor(s.split(",")[0], Integer.parseInt(s.split(",")[1]))).
                collect(Collectors.toList());
        System.out.println(collect);
    }
}
